import { DEFAULTLAYER } from '@/libs/constant'

class StraightLine {
  constructor(props) {
    this.type = 'straightline'
    this.layer = DEFAULTLAYER
    this.startX = props?.startX || 0
    this.startY = props?.startY || 0
    this.endX = this.startX
    this.endY = this.startY
  }

  getType() {
    return this.type
  }

  getLayer() {
    return this.layer
  }

  setEnd(x, y) {
    this.endX = x
    this.endY = y
  }

  draw(ctx) {
    ctx.beginPath()
    ctx.moveTo(this.startX, this.startY)
    ctx.lineTo(this.endX, this.endY)
    ctx.stroke()
  }
}

export default StraightLine
